﻿#region Summary

// 
// Owner : JackieHan 
// 
// Solution : Erp 
// 
// Project : Jackie.Utility.BvConversion
// 
// File : CollectionStringValueConversion.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 集合到String 转换
// 
// History : 
//			2012-06-07 10:02:41	    Create 
// 

#endregion

#region Using

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

#endregion

namespace Jackie.Utility.BvConversion.DefalutValueConversion
{
    ///<summary>
    ///集合到String 转换
    ///</summary>
    public class CollectionStringValueConversion : IValueConversion
    {
        #region Implementation of IValueConversion

        public object GetViewValue(object businessValue)
        {
            var collection = businessValue as IEnumerable;
            if (collection == null) return null;

            var enumerator = collection.GetEnumerator();
            var colString = string.Empty;
            while (enumerator.MoveNext())
            {
                if (enumerator.Current != null)
                    colString += enumerator.Current.ToString() + ",";
            }

            return colString;
        }

        public object GetBusinessValue(object viewValue)
        {
            return null;
        }

        #endregion
    }
}